package com.xc.hotelmgr.order.init;

import com.alibaba.fastjson.JSONObject;
import com.xc.hotelmgr.order.common.utils.Constant;
import com.xc.hotelmgr.order.common.utils.RedisUtils;
import com.xc.hotelmgr.order.modules.order.entity.DtOrderChannelsEntity;
import com.xc.hotelmgr.order.modules.order.service.DtOrderChannelsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.List;

@Component
public class Init {
    @Autowired
    private DtOrderChannelsService dtOrderChannelsService;

    @Autowired
    private RedisUtils redisUtils;

    @PostConstruct
    public void init() {
        List<DtOrderChannelsEntity> ctrips = dtOrderChannelsService.sqlSelectByChanel(Constant.Channel.Ctrip);
        String ctripOrderChannels = JSONObject.toJSONString(ctrips);
        redisUtils.set("ctripOrderChannels",ctripOrderChannels);
    }

}
